package com.css.apps.base.ip.action;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.css.apps.base.ip.model.SIp;
import com.css.db.query.QueryCache;
import com.css.util.Messages;
import com.css.util.StringHelper;
import com.css.webbase.webwork.action.AdminAction;
import com.opensymphony.xwork.Action;

@SuppressWarnings("serial")
public class GetIp extends AdminAction {
	
	private static Log log = LogFactory.getLog(GetIp.class);
	private String uuid = null;
	private SIp sip;

	public GetIp() {
		sip = new SIp();
	}

	@Override
	public String adminGo() {
		try {
			if (StringHelper.isEmpty(uuid)) {
				sip.setOpenFlag("");
				return Action.SUCCESS;
			} else {
				sip = QueryCache.get(SIp.class, uuid);
				if (sip == null) {
					setMessage(Messages.getString("systemMsg.readError"));
					return Action.ERROR;
				}
			}
			return Action.SUCCESS;
		} catch (Exception ex) {
			log.error(ex.getMessage(), ex);
			setMessage(Messages.getString("systemMsg.dbFaild"));
			return Action.ERROR;
		}
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public SIp getSip() {
		return sip;
	}

	public void setSip(SIp sip) {
		this.sip = sip;
	}
}
